home *** CD-ROM | disk | FTP | other *** search
/ PCMania 40 / PCMania CD40_1.iso / disk1 / wincake.ms_ / wincake.bin
Text File  |  1995-10-11  |  28KB  |  881 lines

  1. '**************************************************************************
  2. '* $Header:   G:/SRC/WCW/MSSETUP/VCS/WINCAKE.MSV   1.44   18 Sep 1995 15:02:24   PS  $
  3. '*
  4. '* DESCRIPTION: MS-Setup script for Wincake and Wcwdemo.
  5. '*
  6. '* $Log:   G:/SRC/WCW/MSSETUP/VCS/WINCAKE.MSV  $
  7. '* 
  8. '*    Rev 1.44   18 Sep 1995 15:02:24   PS
  9. '* MSACM no longer installed.
  10. '* 
  11. '*    Rev 1.43   30 Aug 1995 19:05:30   FP
  12. '* Associate BUN files with Cakewalk Pro Audio.
  13. '* 
  14. '*    Rev 1.42   30 Aug 1995 15:08:16   FP
  15. '* RC1 changes to reflect PR name change to Cakewalk Pro Audio.  Bring back
  16. '* install of VPiano.
  17. '* 
  18. '*    Rev 1.41   23 Aug 1995 16:02:14   FP
  19. '* Beta G changes.
  20. '* 
  21. '*    Rev 1.40   16 Aug 1995 11:59:16   FP
  22. '* Beta F changes.
  23. '* 
  24. '*    Rev 1.39   09 Aug 1995 16:14:54   FP
  25. '* Changes for BETA E.
  26. '* 
  27. '*    Rev 1.38   03 Aug 1995 13:18:52   FP
  28. '* Beta D changes.
  29. '* 
  30. '*    Rev 1.37   18 Jul 1995 15:18:42   FP
  31. '* BETA C changes and addition of MSACM.
  32. '* 
  33. '*    Rev 1.36   07 Jul 1995 16:16:44   FP
  34. '* Beta B changes.
  35. '* 
  36. '*    Rev 1.35   16 Jun 1995 16:42:18   FP
  37. '* Added Wave Profiler to Program group.
  38. '* 
  39. '*    Rev 1.34   13 Jun 1995 15:14:34   FP
  40. '* Modified for Edison Beta.  VPiano not installed.
  41. '* 
  42. '*    Rev 1.33   20 Dec 1994 16:16:28   PS
  43. '* Final directory names for 3.01 RC1.
  44. '* 
  45. '*    Rev 1.32   20 Dec 1994 12:53:50   PS
  46. '* Add VPIANO to Pro & Pro Demo.
  47. '* 
  48. '*    Rev 1.31   13 Dec 1994 18:48:20   PS
  49. '* Added DEFAULT.INS, INS_NOT_OVERWRITTEN dialog.
  50. '* 
  51. '*    Rev 1.30   01 Dec 1994 16:43:38   PS
  52. '* New, separate-product production method.  Many changes for 3.01 Beta B.
  53. '*
  54. '*    Rev 1.29   14 Nov 1994 19:31:14   PS
  55. '* Set dest directory for beta testers.
  56. '*
  57. '*    Rev 1.28   11 Nov 1994 19:06:48   PS
  58. '* CAKEXP.EXE.  Allow layout per product.
  59. '*
  60. '*    Rev 1.27   09 May 1994 13:19:02   GH
  61. '* Detect/require 80386 or higher, warn about no mouse.
  62. '*
  63. '*    Rev 1.26   28 Apr 1994 21:26:02   GH
  64. '* Use SRC.INS and MASTER.INS
  65. '*
  66. '*    Rev 1.25   25 Apr 1994 13:40:06   GH
  67. '* For CPW, changed DEST$ to C:\CPW30
  68. '*
  69. '*    Rev 1.24   15 Apr 1994 15:34:48   GH
  70. '* Changes for 2.5 Beta
  71. '*
  72. '*    Rev 1.23   17 Feb 1994 13:17:14   PS
  73. '* Associate .TPL files with us, too.
  74. '*
  75. '*    Rev 1.22   11 Jan 1994 13:47:38   CP
  76. '* Create a Home Studio Demo version.
  77. '*
  78. '*    Rev 1.21   08 Nov 1993 15:41:42   CP
  79. '* Change Lite name from WCWLITE to CAKEHS.
  80. '*
  81. '*    Rev 1.20   23 Aug 1993 14:06:06   CP
  82. '* Default installation directory for Demo is now C:\WCWDEMO to prevent
  83. '* nuking of previous installations.
  84. '*
  85. '*    Rev 1.19   24 May 1993 17:09:22   gwh
  86. '* Removed serial number item from user info prompt.
  87. '*
  88. '*    Rev 1.18   18 Apr 1993 17:50:40   gwh
  89. '* More refinements for user name, organization, serial number stamping.
  90. '*
  91. '*    Rev 1.17   01 Apr 1993 18:32:44   gwh
  92. '* Prompt user for Name, Organization, and Serial number.
  93. '* Stamp the .EXE resources for these items.
  94. '*
  95. '*    Rev 1.16   18 Mar 1993 14:06:42   pws
  96. '* No more need to clean up old DLL's in Windows sys dir (or TTSSEQ.INI).
  97. '* Also check for existence of TTSSEQ.INI in install dir before copying
  98. '* any TTSSEQ.INI found in Windows sys dir before copying new files.
  99. '*
  100. '*    Rev 1.15   05 Mar 1993 12:08:38   pws
  101. '* Fix support for multiple-disk installations, which had broken when
  102. '* we started determining which product we were by testing for the
  103. '* existence of name.EXE on the first diskette but it had been put
  104. '* on the second one.  Now determine which product we are by testing
  105. '* for existence of product-specific section in SETUP.INF file.
  106. '*
  107. '*    Rev 1.14   22 Dec 1992 13:17:36   pws
  108. '* Reflect changed dialog id's in BLDCUI\DIALOGS.H.
  109. '*
  110. '*    Rev 1.13   15 Dec 1992 14:47:18   pws
  111. '* Added CTL3D.DLL.
  112. '*
  113. '*    Rev 1.12   10 Nov 1992 12:37:56   pws
  114. '* Made more dialogs product-specific.
  115. '*
  116. '* ---
  117. '* See logfile for earlier revision comments
  118. '*
  119. '* Copyright (C) 1990- by Greg Hendershott.  All rights reserved.
  120. '**************************************************************************
  121.  
  122. '$INCLUDE 'setupapi.inc'
  123. '$INCLUDE 'msdetect.inc'
  124. '$INCLUDE 'msregdb.inc'
  125.  
  126. 'These should have all been in SETUPAPI.INC.
  127. 'Note that duplicate definitions are errors and so are commented out!
  128.  
  129. 'CONST MB_OK                = &H0000
  130. CONST MB_OKCANCEL            = &H0001
  131. CONST MB_ABORTRETRYIGNORE    = &H0002
  132. CONST MB_YESNOCANCEL        = &H0003
  133. CONST MB_YESNO                = &H0004
  134. CONST MB_RETRYCANCEL        = &H0005
  135. CONST MB_TYPEMASK            = &H000F
  136.  
  137. 'CONST MB_ICONHAND            = &H0010
  138. CONST MB_ICONQUESTION        = &H0020
  139. CONST MB_ICONEXCLAMATION    = &H0030
  140. CONST MB_ICONASTERISK        = &H0040
  141. CONST MB_ICONMASK            = &H00F0
  142.  
  143. CONST MB_ICONINFORMATION    = MB_ICONASTERISK
  144. CONST MB_ICONSTOP            = MB_ICONHAND
  145.  
  146. CONST MB_DEFBUTTON1            = &H0000
  147. CONST MB_DEFBUTTON2            = &H0100
  148. CONST MB_DEFBUTTON3            = &H0200
  149. CONST MB_DEFMASK            = &H0F00
  150.  
  151. CONST MB_APPLMODAL            = &H0000
  152. CONST MB_SYSTEMMODAL        = &H1000
  153. 'CONST MB_TASKMODAL            = &H2000
  154.  
  155. CONST MB_NOFOCUS            = &H8000
  156.  
  157. CONST IDOK                    = 1
  158. CONST IDCANCEL                = 2
  159. CONST IDABORT                = 3
  160. CONST IDRETRY                = 4
  161. CONST IDIGNORE                = 5
  162. CONST IDYES                    = 6
  163. CONST IDNO                    = 7
  164.  
  165. 'Dialog ID's.  NOTE: THIS MUST MATCH BLDCUI\DIALOGS.H!
  166. CONST WELCOME_PR            = 170
  167. CONST WELCOME_PD            = 171
  168. CONST WELCOME_HS            = 172
  169. CONST WELCOME_HD            = 173
  170. CONST WELCOME_XP            = 174
  171. CONST WELCOME_XD            = 175
  172. CONST ASKQUIT                = 200
  173. CONST DESTPATH                = 300
  174. CONST USERINFO                = 310
  175. CONST EXITFAILURE            = 400
  176. CONST EXITQUIT_PR            = 670
  177. CONST EXITQUIT_PD            = 671
  178. CONST EXITQUIT_HS            = 672
  179. CONST EXITQUIT_HD            = 673
  180. CONST EXITQUIT_XP            = 674
  181. CONST EXITQUIT_XD            = 675
  182. CONST EXITSUCCESS_PR        = 770
  183. CONST EXITSUCCESS_PD        = 771
  184. CONST EXITSUCCESS_HS        = 772
  185. CONST EXITSUCCESS_HD        = 773
  186. CONST EXITSUCCESS_XP        = 774
  187. CONST EXITSUCCESS_XD        = 775
  188. CONST APPHELP_PR            = 970
  189. CONST APPHELP_PD            = 971
  190. CONST APPHELP_HS            = 972
  191. CONST APPHELP_HD            = 973
  192. CONST APPHELP_XP            = 974
  193. CONST APPHELP_XD            = 975
  194. CONST INI_NOT_OVERWRITTEN    = 1000
  195. CONST INS_NOT_OVERWRITTEN    = 1100
  196. CONST BADPATH                = 6400
  197.  
  198. 'Bitmap ID.
  199. CONST LOGO = 1
  200.  
  201. GLOBAL COMPANY$
  202. GLOBAL PROGNAME$
  203. GLOBAL PRODUCTNAME$
  204. GLOBAL DEST$        'Default destination directory.
  205.  
  206. DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  207. DECLARE SUB MaybeAssociate (szExt$)
  208. DECLARE SUB SafeCopy(szShort$, szLong$)
  209. DECLARE FUNCTION ArgStr$ (Fmt$, Arg1$, Arg2$, Arg3$, Arg4$)
  210.  
  211. INIT:
  212. '======== beg LOCALIZATION ========
  213. 'These are the strings that need to be localized for different languages.
  214. 'Every one of them is located right here in this block.
  215.     CONST COMPANY_$ = "Twelve Tone Systems"
  216.     CONST PRODUCTNAME_PR_$ = "Cakewalk Pro Audio"
  217.     CONST PRODUCTNAME_PD_$ = "Cakewalk Pro Audio Demo"
  218.     CONST PRODUCTNAME_HS_$ = "Cakewalk Home Studio"
  219.     CONST PRODUCTNAME_HD_$ = "Cakewalk Home Studio Demo"
  220.     CONST PRODUCTNAME_XP_$ = "Cakewalk Express"
  221.     CONST PRODUCTNAME_XD_$ = "Cakewalk Express Demo"
  222.     CONST PROGMANGROUPNAME_PR_$ = "Cakewalk Pro Audio"
  223.     CONST PROGMANGROUPNAME_HS_$ = "Cakewalk Home Studio"
  224.     CONST PROGMANGROUPNAME_XP_$ = "Cakewalk Express"
  225.     CONST SETUP_$ = "Setup"
  226.     CONST SetTitleFmt_$ = "\1 \2"
  227.     CONST setupMessage_$ = "Setup Message"
  228.     CONST setupProblem_$ = "Setup Problem"
  229.     CONST setupQuestion_$ = "Setup Question"
  230.     CONST winVerFmt_$ = "Sorry, but your Windows version is \1 and \2 requires at least Windows \3."
  231.     CONST cpuFmt_$ = "Sorry, but \1 requires at least an 80386 or higher CPU."
  232.     CONST mouseFmt_$ = "Please be aware that \1 requires a mouse for many operations."
  233.     CONST errQuitFmt_$ = "Installation failure.  Call \1 Technical Support."
  234.     CONST driveBase_$ = "A"        'drive letters start at this char
  235.     CONST dskSpcFmt_$ = "Sorry, \1 needs \2K bytes more (\3K total) on drive \4:.  Clear space or try a new path."
  236.     CONST userInfoNeedName_$ = "You must supply your name or Setup cannot proceed."
  237.     CONST assocConfirmFmt_$ = ".\1 files are currently associated with \2.  Switch association to \3?"
  238.     CONST PRODUCTNAME_VP_$ = "Virtual Piano"
  239.     CONST instMustRestartWinFmt_$ = "\1 installed.  You must restart Windows before it can be used."
  240. '======== end LOCALIZATION ========
  241.  
  242.     CUIDLL$ = "mscuistf.dll"        'Custom user interface dll
  243.     HELPPROC$ = "FHelpDlgProc"        'Help dialog procedure
  244.  
  245.     'Determine full SETUP.INF path+name (same name for all products).
  246.     szInf$ = GetSymbolValue("STF_SRCINFPATH")
  247.     IF szInf$ = "" THEN
  248.         szInf$ = GetSymbolValue("STF_CWDDIR") + "SETUP.INF"
  249.     END IF
  250.     ReadInfFile szInf$
  251.  
  252.     'Determine which product we are by seeing which .EXE name reference key
  253.     'is defined.  In DSKLAYT we specified a reference key for the .EXE which
  254.     'is the same as PROGNAME$.  This key is also used for StampResource below.
  255.     IF DoesIniKeyExist(szInf$, "Files", """CAKEAUD""") <> 0 THEN
  256.         PROGNAME$ = "CAKEAUD"
  257.         PRODUCTNAME$ = PRODUCTNAME_PR_$
  258.         PROGMANGROUPNAME$ = PROGMANGROUPNAME_PR_$
  259.         INIBASENAME$ = "WINCAKE"
  260.         DEST$ = "C:\CAKEAUD"        '4.0 normal
  261.     ELSEIF DoesIniKeyExist(szInf$, "Files", """WCWDEMO""") <> 0 THEN
  262.         PROGNAME$ = "WCWDEMO"
  263.         PRODUCTNAME$ = PRODUCTNAME_PD_$
  264.         PROGMANGROUPNAME$ = PROGMANGROUPNAME_PR_$
  265.         INIBASENAME$ = "WINCAKE"
  266.         DEST$ = "C:\WCWDEMO"
  267.     ELSEIF DoesIniKeyExist(szInf$, "Files", """CAKEHS""") <> 0 THEN
  268.         PROGNAME$ = "CAKEHS"
  269.         PRODUCTNAME$ = PRODUCTNAME_HS_$
  270.         PROGMANGROUPNAME$ = PROGMANGROUPNAME_HS_$
  271.         INIBASENAME$ = "CAKEHS"
  272.         DEST$ = "C:\CAKEHS"        'normal
  273. '        DEST$ = "C:\CHS301"        'temp during beta test period
  274.     ELSEIF DoesIniKeyExist(szInf$, "Files", """CHSDEMO""") <> 0 THEN
  275.         PROGNAME$ = "CHSDEMO"
  276.         PRODUCTNAME$ = PRODUCTNAME_HD_$
  277.         PROGMANGROUPNAME$ = PROGMANGROUPNAME_HS_$
  278.         INIBASENAME$ = "CAKEHS"
  279.         DEST$ = "C:\CHSDEMO"
  280.     ELSEIF DoesIniKeyExist(szInf$, "Files", """CAKEXP""") <> 0 THEN
  281.         PROGNAME$ = "CAKEXP"
  282.         PRODUCTNAME$ = PRODUCTNAME_XP_$
  283.         PROGMANGROUPNAME$ = PROGMANGROUPNAME_XP_$
  284.         INIBASENAME$ = "CAKEXP"
  285.         DEST$ = "C:\CAKEXP"        'normal
  286. '        DEST$ = "C:\CXP301"        'temp during beta test period
  287.     ELSEIF DoesIniKeyExist(szInf$, "Files", """CAKEXPD""") <> 0 THEN
  288.         PROGNAME$ = "CAKEXPD"
  289.         PRODUCTNAME$ = PRODUCTNAME_XD_$
  290.         PROGMANGROUPNAME$ = PROGMANGROUPNAME_XP_$
  291.         INIBASENAME$ = "CAKEXP"
  292.         DEST$ = "C:\CAKEXPD"
  293.     ELSE
  294.         GOTO ERRQUIT
  295.     END IF
  296.  
  297.     SetBitmap CUIDLL$, LOGO
  298.     SetTitle ArgStr$(SetTitleFmt_$, PRODUCTNAME$, SETUP_$, "", "")
  299.  
  300.     'Check Windows version.
  301.     winVerReqd$ = "3.1"
  302.     winVer$ = LTRIM$( STR$( GetWindowsMajorVersion() ) ) + "." + LTRIM$( STR$( GetWindowsMinorVersion() ) )
  303.     IF winVer$ < winVerReqd$ THEN        'string sort works
  304.         i% = DoMsgBox( ArgStr$(winVerFmt_$, winVer$, PRODUCTNAME$, winVerReqd$, ""), setupMessage_$, MB_OK+MB_TASKMODAL+MB_ICONHAND )
  305.         END    'exit SETUP
  306.     END IF
  307.  
  308.     'Check CPU.
  309.     cpu% = GetProcessorType()    '2==80286, 3==80386, 4==80486
  310.     IF cpu% < 3 THEN
  311.         i% = DoMsgBox( ArgStr$(cpuFmt_$, PRODUCTNAME$, "", "", ""), setupMessage_$, MB_OK+MB_TASKMODAL+MB_ICONSTOP )
  312.         END    'exit SETUP
  313.     END IF
  314.  
  315.     'Check for mouse.
  316.     IF HasMouseInstalled() = 0 THEN
  317.         i% = DoMsgBox( ArgStr$(mouseFmt_$, PRODUCTNAME$, "", "", ""), setupMessage_$, MB_OK+MB_TASKMODAL+MB_ICONINFORMATION )
  318.     END IF
  319.  
  320.     'Disk cost list symbols.
  321.     FILECOSTS$   = "FileCosts"
  322.     EXTRACOSTS$  = "ExtraCosts"
  323.     STILLNEEDED$ = "StillNeeded"
  324.     FOR i% = 1 TO 26 STEP 1
  325.         AddListItem EXTRACOSTS$, "0"
  326.     NEXT i%
  327.     'Add extra cost to Windows drive for ini/progman, etc.
  328.     ixWinDrive% = ASC(UCASE$( MID$(GetWindowsDir(), 1, 1) )) - ASC("A") + 1
  329.     ReplaceListItem EXTRACOSTS$, ixWinDrive%, "10240"
  330.  
  331.  
  332. WELCOME:
  333.     IF PROGNAME$ = "CAKEAUD" THEN
  334.         dlg% = WELCOME_PR
  335.         dlghelp% = APPHELP_PR
  336.     ELSEIF PROGNAME$ = "WCWDEMO" THEN
  337.         dlg% = WELCOME_PD
  338.         dlghelp% = APPHELP_PD
  339.     ELSEIF PROGNAME$ = "CAKEHS" THEN
  340.         dlg% = WELCOME_HS
  341.         dlghelp% = APPHELP_HS
  342.     ELSEIF PROGNAME$ = "CHSDEMO" THEN
  343.         dlg% = WELCOME_HD
  344.         dlghelp% = APPHELP_HD
  345.     ELSEIF PROGNAME$ = "CAKEXP" THEN
  346.         dlg% = WELCOME_XP
  347.         dlghelp% = APPHELP_XP
  348.     ELSEIF PROGNAME$ = "CAKEXPD" THEN
  349.         dlg% = WELCOME_XD
  350.         dlghelp% = APPHELP_XD
  351.     END IF
  352.     sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfoDlgProc", dlghelp%, HELPPROC$)
  353.     IF sz$ = "CONTINUE" THEN
  354.         UIPop 1
  355.     ELSE
  356.         GOSUB ASKQUIT
  357.         GOTO WELCOME
  358.     END IF
  359.  
  360.  
  361. GETPATH:
  362.     SetSymbolValue "EditTextIn", DEST$
  363.     SetSymbolValue "EditFocus", "END"
  364. GETPATHL1:
  365.     sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", dlghelp%, HELPPROC$)
  366.     DEST$ = GetSymbolValue("EditTextOut")
  367.  
  368.     IF sz$ = "CONTINUE" THEN
  369.         IF IsDirWritable(DEST$) = 0 THEN
  370.             GOSUB BADPATH
  371.             GOTO GETPATHL1
  372.         END IF
  373.         UIPop 1
  374.         ixAppDrive% = ASC(UCASE$( MID$(DEST$, 1, 1) )) - ASC(driveBase_$) + 1
  375.     ELSEIF sz$ = "REACTIVATE" THEN
  376.         GOTO GETPATHL1
  377.     ELSEIF sz$ = "BACK" THEN
  378.         UIPop 1
  379.         GOTO WELCOME
  380.     ELSE
  381.         GOSUB ASKQUIT
  382.         GOTO GETPATH
  383.     END IF
  384.  
  385. 'Install.
  386.     GOSUB INSTALL
  387.     IF StillNeed& > 0 THEN
  388.         GOTO GETPATH
  389.     END IF
  390.  
  391. QUIT:
  392.     ON ERROR GOTO ERRQUIT
  393.  
  394.     IF ERR = 0 THEN
  395.         IF PROGNAME$ = "CAKEAUD" THEN
  396.             dlg% = EXITSUCCESS_PR
  397.         ELSEIF PROGNAME$ = "WCWDEMO" THEN
  398.             dlg% = EXITSUCCESS_PD
  399.         ELSEIF PROGNAME$ = "CAKEHS" THEN
  400.             dlg% = EXITSUCCESS_HS
  401.         ELSEIF PROGNAME$ = "CHSDEMO" THEN
  402.             dlg% = EXITSUCCESS_HD
  403.         ELSEIF PROGNAME$ = "CAKEXP" THEN
  404.             dlg% = EXITSUCCESS_XP
  405.         ELSEIF PROGNAME$ = "CAKEXPD" THEN
  406.             dlg% = EXITSUCCESS_XD
  407.         END IF
  408.     ELSEIF ERR = STFQUIT THEN
  409.         IF PROGNAME$ = "CAKEAUD" THEN
  410.             dlg% = EXITQUIT_PR
  411.         ELSEIF PROGNAME$ = "WCWDEMO" THEN
  412.             dlg% = EXITQUIT_PD
  413.         ELSEIF PROGNAME$ = "CAKEHS" THEN
  414.             dlg% = EXITQUIT_HS
  415.         ELSEIF PROGNAME$ = "CHSDEMO" THEN
  416.             dlg% = EXITQUIT_HD
  417.         ELSEIF PROGNAME$ = "CAKEXP" THEN
  418.             dlg% = EXITQUIT_XP
  419.         ELSEIF PROGNAME$ = "CAKEXPD" THEN
  420.             dlg% = EXITQUIT_XD
  421.         END IF
  422.     ELSE
  423.         dlg% = EXITFAILURE
  424.     END IF
  425. QUITL1:
  426.     sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
  427.     IF sz$ = "REACTIVATE" THEN
  428.         GOTO QUITL1
  429.     END IF
  430.     UIPop 1
  431.  
  432.     END
  433.  
  434. ERRQUIT:
  435.     i% = DoMsgBox(ArgStr$(errQuitFmt_$, COMPANY_$, "", "", ""), setupMessage_$, MB_OK+MB_TASKMODAL+MB_ICONHAND)
  436.     END
  437.  
  438.  
  439.  
  440. BADPATH:
  441.     sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
  442.     IF sz$ = "REACTIVATE" THEN
  443.         GOTO BADPATH
  444.     END IF
  445.     UIPop 1
  446.     RETURN
  447.  
  448.  
  449.  
  450. ASKQUIT:
  451.     sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
  452.  
  453.     IF sz$ = "EXIT" THEN
  454.         UIPopAll
  455.         ERROR STFQUIT
  456.     ELSEIF sz$ = "REACTIVATE" THEN
  457.         GOTO ASKQUIT
  458.     ELSE
  459.         UIPop 1
  460.     END IF
  461.     RETURN
  462.  
  463.  
  464.  
  465. '**
  466. '**    Purpose:
  467. '**        Builds the copy list and performs all installation operations.
  468. '**    Arguments:
  469. '**        none.
  470. '**    Returns:
  471. '**        none.
  472. '*************************************************************************
  473. INSTALL:
  474.  
  475.     'Get user information; we'll stamp later.
  476.     GOSUB DOUSERINFODIALOG
  477.  
  478.     SrcDir$ = GetSymbolValue("STF_SRCDIR")
  479.  
  480.     'These (normal) files go to the user's specifed app destination directory.
  481.     AddSectionFilesToCopyList "Files", SrcDir$, DEST$
  482.     
  483.     'These files go to the Windows System directory.
  484.     AddSectionFilesToCopyList "system", SrcDir$, GetWindowsSysDir()
  485.     
  486.     StillNeed& = GetCopyListCost(EXTRACOSTS$, FILECOSTS$, STILLNEEDED$)
  487.     IF StillNeed& > 0 THEN
  488.         ClearCopyList
  489.         FOR ix% = 1 TO 26 STEP 1    'find first drive that needs space
  490.             need1& = VAL(GetListItem(STILLNEEDED$, ix%))
  491.             IF need1& > 0 THEN
  492.                 GOTO FNDDRV
  493.             END IF
  494.         NEXT ix%
  495.         ix = ixAppDrive                '(shouldn't happen)
  496.         need1& = 0
  497.         StillNeed& = 1
  498. FNDDRV:
  499.         need$  = LTRIM$(STR$( (need1&+1023) / 1024 ))
  500.         cost$  = LTRIM$(STR$( (VAL(GetListItem(FILECOSTS$, ix%))+1023) / 1024 ))
  501.         drive$ = CHR$(ix% - 1 + ASC(driveBase_$))
  502.         msg$ = ArgStr$(dskSpcFmt_$, PRODUCTNAME$, need$, cost$, drive$)
  503.         i% = DoMsgBox(msg$, setupProblem_$, MB_RETRYCANCEL+MB_TASKMODAL+MB_ICONHAND)
  504.         IF i% = IDCANCEL THEN
  505.             GOSUB ASKQUIT
  506.         END IF
  507.         RETURN        'must RETURN out of GOSUB to pop stack, not just GOTO
  508.     END IF
  509.  
  510.     CreateDir DEST$, cmoNone
  511.  
  512.     OpenLogFile MakePath(DEST$, "LOGFILE.OUT"), 0
  513.     WriteToLogFile ""
  514.     WriteToLogFile "User chose as destination directory: '" + DEST$ + "'"
  515.     WriteToLogFile "May have had to create the directory: " + DEST$
  516.     WriteToLogFile ""
  517.  
  518.     CopyFilesInCopyList
  519.  
  520.     'Important: Do this here before any dialogs with an Exit button, so
  521.     'user cannot avoid stamping.
  522.     GOSUB STAMPUSERINFO
  523.  
  524.     SetRegKeyValue PROGNAME$, PRODUCTNAME$
  525.     SetRegKeyValue PROGNAME$+"\shell\print", ""
  526.     SetRegKeyValue PROGNAME$+"\shell\open\command", MakePath(DEST$,PROGNAME$+".EXE") + " %1"
  527.     MaybeAssociate "wrk"
  528.     MaybeAssociate "mid"
  529.     MaybeAssociate "mff"
  530.     MaybeAssociate "tpl"
  531.     MaybeAssociate "bun"
  532.  
  533. 'Deal with old installation where our app DLL's were in WINDOWS\SYSTEM.
  534. 'No more need to delete old DLL's, since we don't use any with same name now.
  535. 'If old TTSSEQ.INI exists in sysdir but not in appdir, copy it now to preserve settings.
  536.     SysDir$ = GetWindowsSysDir()
  537.     IF DoesFileExist(SysDir$+"TTSSEQ.INI",femExists) <> 0 AND DoesFileExist(DEST$+"TTSSEQ.INI",femExists) = 0 THEN
  538.         CopyFile SysDir$+"TTSSEQ.INI", DEST$+"\TTSSEQ.INI", cmoNone, 0
  539.     END IF
  540.  
  541. 'If this product includes sysx input support, then it includes DRM.INI, which
  542. 'is the base version of progname.INI containing just the DRM's.
  543. 'So if this product includes DRM.INI, then copy it to progname.INI, except if
  544. 'progname.INI already exists, in which case we inform the user that we didn't
  545. 'overwrite it and he might want to look for new DRM's in DRM.INI.
  546.     drm$ = MakePath(DEST$, "DRM.INI")
  547.     ini$ = MakePath(DEST$, INIBASENAME$+".INI")
  548.     IF DoesFileExist(drm$,femExists) <> 0 THEN    'if this product includes DRM.INI
  549.         IF DoesFileExist(ini$,femExists) = 0 THEN
  550.             CopyFile drm$, ini$, cmoVital, 0
  551.         ELSE
  552.             sz$ = UIStartDlg(CUIDLL$, INI_NOT_OVERWRITTEN, "FInfoDlgProc", 0, "")
  553.             IF sz$ = "EXIT" THEN
  554.                 GOSUB ASKQUIT
  555.             ELSE
  556.                 UIPop 1
  557.             END IF
  558.         END IF
  559.     END IF
  560.  
  561. 'SRC.INS (complete .INS) was copied over with no name change.
  562. 'DEFAULT.INS (basic default .INS) will be copied to MASTER.INS, which is
  563. 'what the program actually uses, but only if it doesn't already exist.
  564.     default$ = MakePath(DEST$, "DEFAULT.INS")
  565.     master$  = MakePath(DEST$, "MASTER.INS")
  566.     IF DoesFileExist(master$,femExists) = 0 THEN
  567.         CopyFile default$, master$, cmoVital, 0
  568.     ELSE
  569.         sz$ = UIStartDlg(CUIDLL$, INS_NOT_OVERWRITTEN, "FInfoDlgProc", 0, "")
  570.         IF sz$ = "EXIT" THEN
  571.             GOSUB ASKQUIT
  572.         ELSE
  573.             UIPop 1
  574.         END IF
  575.     END IF
  576.  
  577.     CreateProgmanGroup PROGMANGROUPNAME$, "", cmoNone
  578.     ShowProgmanGroup  PROGMANGROUPNAME$, 1, cmoNone
  579.     CreateProgmanItem PROGMANGROUPNAME$, PRODUCTNAME$, MakePath(DEST$,PROGNAME$+".EXE"), "", cmoOverwrite
  580.     CreateProgmanItem PROGMANGROUPNAME$, "README.WRI", "write.exe "+MakePath(DEST$,"readme.wri"), "", cmoOverwrite
  581.     CreateProgmanItem PROGMANGROUPNAME$, "Wave Profiler", ""+MakePath(DEST$,"waveprof.exe"), "", cmoOverwrite
  582.  
  583. '    Add MSACM - Microsoft Compression Manager
  584. '    CreateIniKeyValue GetWindowsDir() + "system.ini", "Drivers", "WaveMapper", "msacm.drv", cmoOverwrite
  585. '    CreateIniKeyValue GetWindowsDir() + "control.ini", "drivers.desc", "msacm.drv", "Microsoft Sound Mapper V2.00", cmoOverwrite
  586.  
  587.     WriteToLogFile ""
  588.  
  589.     GOSUB INSTALL_VPIANO
  590.  
  591.     WriteToLogFile "SUB Install completed."
  592.     CloseLogFile
  593.  
  594.     RETURN
  595.  
  596.  
  597.  
  598. '**
  599. '**    Purpose:
  600. '**        Install a file without replacing an existing one.
  601. '**    Arguments:
  602. '**        szShort$ - Name like SRC.INS
  603. '**        szLong$     - Name like MASTER.INS
  604. '*************************************************************************
  605. SUB SafeCopy (szShort$, szLong$) STATIC
  606.     szShortPathName$ = MakePath(DEST$, szShort$)
  607.     szLongPathName$ = MakePath(DEST$, szLong$)
  608.     IF DoesFileExist(szLongPathName$,femExists) = 0 THEN
  609.         CopyFile szShortPathName$, szLongPathName$, cmoVital, 0
  610.     END IF
  611. END SUB
  612.  
  613.  
  614.  
  615. '**
  616. '**    Purpose:
  617. '**        Appends a file name to the end of a directory path,
  618. '**        inserting a backslash character as needed.
  619. '**    Arguments:
  620. '**        szDir$  - full directory path (with optional ending "\")
  621. '**        szFile$ - filename to append to directory
  622. '**    Returns:
  623. '**        Resulting fully qualified path name.
  624. '*************************************************************************
  625. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  626.     IF szDir$ = "" THEN
  627.         MakePath = szFile$
  628.     ELSEIF szFile$ = "" THEN
  629.         MakePath = szDir$
  630.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  631.         MakePath = szDir$ + szFile$
  632.     ELSE
  633.         MakePath = szDir$ + "\" + szFile$
  634.     END IF
  635. END FUNCTION
  636.  
  637.  
  638.  
  639. '**
  640. '**    Purpose:
  641. '**    Arguments:
  642. '**    Returns:
  643. '**        none.
  644. '*************************************************************************
  645. DOUSERINFODIALOG:
  646. 'Get user info for stamping later.
  647.     IF PROGNAME$ <> "WCWDEMO" AND PROGNAME$ <> "CHSDEMO" AND PROGNAME$ <> "CAKEXPD" THEN
  648. GETUSERINFO:
  649.         sz$ = UIStartDlg(CUIDLL$, USERINFO, "FNameOrgDlgProc", dlghelp%, HELPPROC$)
  650.         IF sz$ = "REACTIVATE" THEN
  651.             GOTO GETUSERINFO
  652.         END IF
  653.  
  654.         szUser$ = GetSymbolValue( "NameOut" )
  655.         szCo$ = GetSymbolValue( "OrgOut" )
  656.  
  657.         'Company may be blank, but not the other two.
  658.         IF szUser$ = "" THEN
  659.             i% = DoMsgBox(userInfoNeedName_$, setupProblem_$, MB_OK+MB_TASKMODAL+MB_ICONHAND)
  660.             GOTO GETUSERINFO
  661.         END IF
  662.  
  663.         'Dismiss dialog now that we've validated.
  664.         UIPop 1
  665.     END IF
  666.  
  667.     RETURN
  668.  
  669.  
  670. '**
  671. '**    Purpose:
  672. '**    Arguments:
  673. '**    Returns:
  674. '**        none.
  675. '*************************************************************************
  676. STAMPUSERINFO:
  677. 'Stamp user info into our .EXE file.
  678.     IF PROGNAME$ <> "WCWDEMO" AND PROGNAME$ <> "CHSDEMO" AND PROGNAME$ <> "CAKEXPD" THEN
  679.  
  680.         'szUser$ szCo$ were prompted for above.
  681.         szDat$ = CHR$(LEN(szUser$)) + szUser$
  682.         szDat$ = szDat$ + CHR$(LEN(szCo$)) + szCo$
  683.  
  684.         '"Files" is the section name in our .INF file of the .EXE file.
  685.         '
  686.         '6 is the resource type for STRINGTABLE entries.
  687.         '
  688.         '&H401 is the upper 12 bits of IDS_USERNAME (0x4000) + 1.
  689.         '
  690.         'In DSKLAYT we specified a reference key for the .EXE which
  691.         'is the same as PROGNAME$.
  692.         StampResource "Files",PROGNAME$,DEST$,6,&H401,szDat$,LEN(szDat$)
  693.     END IF
  694.  
  695.     RETURN
  696.  
  697.  
  698. '**
  699. '**    Purpose:
  700. '**        Associates given filetype with us, but asks for user confirmation
  701. '**        if already set to something else.
  702. '**    Arguments:
  703. '**        szExt$ - filetype extension, e.g. "mid"
  704. '**    Returns:
  705. '**        none.
  706. '*************************************************************************
  707. SUB MaybeAssociate (szExt$) STATIC
  708.     oldProg$ = ""
  709.     ok% = IDYES
  710.  
  711. 'Check Registration Database (overrides WIN.INI [Extensions]).
  712.  
  713.     oldCmd$ = UCASE$( LTRIM$( GetRegKeyValue("."+szExt$+"\shell\open\command") ) )
  714.     IF oldCmd$ = "" THEN    'didn't find direct association, check via prog name
  715.         oldProg$ = LTRIM$( RTRIM$( GetRegKeyValue("."+szExt$) ) )
  716.         IF oldProg$ <> "" THEN
  717.             oldCmd$ = UCASE$( LTRIM$( GetRegKeyValue(oldProg$+"\shell\open\command") ) )
  718.             oldProduct$ = LTRIM$( RTRIM$( GetRegKeyValue(oldProg$) ) )
  719.             IF oldProduct$ <> "" THEN    'long product name found, use it
  720.                 oldProg$ = oldProduct$
  721.             END IF
  722.         END IF
  723.     END IF
  724.     IF oldCmd$ <> "" THEN
  725.         IF INSTR(oldCmd$, PROGNAME$+".EXE") = 0 THEN    'not us, must confirm
  726.             IF oldProg$ = "" THEN   'no short or long name, parse command string
  727.                 j% = INSTR(oldCmd$, " ")
  728.                 IF j% > 1 THEN
  729.                     oldProg$ = MID$(oldCmd$, 1, j%-1)
  730.                 ELSE
  731.                     oldProg$ = oldCmd$
  732.                 END IF
  733.             END IF
  734.         ELSE                    'it's us, clear oldProg$ => no confirm
  735.             oldProg$ = ""
  736.         END IF
  737.         GOTO MAYBE_CONFIRM        'found association, no need to examine WIN.INI
  738.     END IF
  739.  
  740. 'Check WIN.INI [Extensions].
  741.  
  742.     oldCmd$ = UCASE$( LTRIM$( GetIniKeyString("WIN.INI","Extensions",szExt$) ) )
  743.     IF oldCmd$ <> "" THEN
  744.         IF INSTR(oldCmd$, PROGNAME$+".EXE") = 0 THEN    'not us, must confirm
  745.             j% = INSTR(oldCmd$, " ")
  746.             IF j% > 1 THEN
  747.                 oldProg$ = MID$(oldCmd$, 1, j%-1)
  748.             ELSE
  749.                 oldProg$ = oldCmd$
  750.             END IF
  751.         END IF
  752.     END IF
  753.  
  754. 'Get user confirmation if necessary, and do the association if ok.
  755.  
  756. MAYBE_CONFIRM:
  757.     IF oldProg$ <> "" THEN
  758.         ok% = DoMsgBox(ArgStr$(assocConfirmFmt_$, UCASE$(szExt$), oldProg$, PRODUCTNAME$, ""), setupQuestion_$, MB_YESNO+MB_TASKMODAL+MB_ICONQUESTION)
  759.     END IF
  760.  
  761.     IF ok% = IDYES THEN
  762.         DeleteRegKey   "."+szExt$    'delete all keys for any old direct association
  763.         SetRegKeyValue "."+szExt$, PROGNAME$
  764.         CreateIniKeyValue "WIN.INI", "Extensions", szExt$, MakePath(DEST$,PROGNAME$+".EXE") + " ^." + szExt$, cmoOverwrite
  765.     END IF
  766.  
  767. END SUB
  768.  
  769.  
  770. '**
  771. '**    Purpose:
  772. '**        Installs Virtual Piano and its driver, if part of this product.
  773. '**    Arguments:
  774. '**        none.
  775. '**    Returns:
  776. '**        none.
  777. '**    WARNING:
  778. '**        The current method used here only works with Windows 3.1!
  779. '*************************************************************************
  780. INSTALL_VPIANO:
  781.  
  782. 'If this product doesn't include the Virtual Piano, return now.
  783. '(Currently all products include it.)
  784.  
  785. 'Set up the Virtual Piano program icon.
  786.  
  787.     CreateProgmanItem PROGMANGROUPNAME$, PRODUCTNAME_VP_$, MakePath(DEST$,"VPIANO.EXE"), "", cmoOverwrite
  788.  
  789. 'Display message that it was installed and Windows should be restarted.
  790.  
  791.     i% = DoMsgBox( ArgStr$(instMustRestartWinFmt_$, PRODUCTNAME_VP_$, "", "", ""), setupMessage_$, MB_OK+MB_TASKMODAL+MB_ICONINFORMATION )
  792.  
  793. 'If there's already a SYSTEM.INI [drivers] MIDIn key set to us, we're done.
  794. 'Else find next available SYSTEM.INI [drivers] MIDIn key.
  795.  
  796.     szSysIni$ = GetWindowsDir()+"SYSTEM.INI"
  797.     szSect$ = "drivers"
  798.     szValue$ = "vpiano.drv"
  799.     szKey$ = "MIDI99"
  800.  
  801.     FOR i% = 0 TO 98 STEP 1
  802.         IF i% = 0 THEN
  803.             szKeyThis$ = "MIDI"
  804.         ELSE
  805.             szKeyThis$ = "MIDI" + LTRIM$( STR$(i%) )
  806.         END IF
  807.  
  808.         szOldValue$ = LCASE$( GetIniKeyString(szSysIni$,szSect$,szKeyThis$) )
  809.         IF szOldValue$ = szValue$ THEN
  810.             RETURN                    'already set, we're done
  811.         ELSEIF szOldValue$ = "" AND szKey$ = "MIDI99" THEN
  812.             szKey$ = szKeyThis$        'found next key, remember it
  813.         END IF
  814.     NEXT i%
  815.  
  816. 'Found next available SYSTEM.INI [drivers] MIDIn key.  Set it to point to us.
  817.  
  818.     CreateIniKeyValue szSysIni$, szSect$, szKey$, szValue$, cmoNone
  819.  
  820.     RETURN
  821.  
  822.  
  823.  
  824. '**
  825. '**    Purpose:
  826. '**        Substitutes string args by number into a format string.
  827. '**        Useful for localization, since arg order is now controlled by Fmt$.
  828. '**        The backslash is used as an escape char.
  829. '**        A backslash followed by a digit string substitutes that arg num.
  830. '**        A backslash not followed by digits subs in the next literal char.
  831. '**    Arguments:
  832. '**        Fmt$  - format string containing instances of \N, N is arg num
  833. '**        ArgN$ - string arg to sub in for each instance of \N
  834. '**    Returns:
  835. '**        Final output string with all arg substitution done.
  836. '**    Example:
  837. '**        Fmt$ = "\\1 = \1, \\2 = \2, \\3 = \3, \\Z = \Z, \\11 = \11."
  838. '**        Out$ = ArgStr$(Fmt$, "Arg1", "Arg2", "", "")
  839. '**        REM ...This sets Out$ to "\1 = Arg1, \2 = Arg2, \3 = , \Z = Z, \11 = ."
  840. '*************************************************************************
  841. FUNCTION ArgStr$ (Fmt$, Arg1$, Arg2$, Arg3$, Arg4$) STATIC
  842.  
  843.     rtn$ = Fmt$        'our returned output string is built here
  844.     esc$ = "\"        'this is the esc char we use
  845.     i% = 1            'current index into string
  846.  
  847.     WHILE 1
  848.         i% = INSTR(i%, rtn$, esc$)    'loc of next esc char
  849.         IF i% = 0 THEN
  850.             EXIT WHILE                'no more esc chars, quit
  851.         END IF
  852.         j% = i% + 1
  853.         WHILE j% <= LEN(rtn$) AND INSTR("0123456789", MID$(rtn$, j%, 1)) <> 0
  854.             j% = j% + 1
  855.         WEND                'i%+1 is start of number string, j% is end+1
  856.         IF j% = i% + 1 THEN    'digit string empty, drop esc char and take next char as literal
  857.             rtn$ = MID$(rtn$, 1, i% - 1) + MID$(rtn$, j%)
  858.             i% = i% + 1                'next search pos in string
  859.         ELSE                'digit string non-empty, read int and sub in arg
  860.             num% = VAL(MID$(rtn$, i% + 1, j% - i% - 1))
  861.             SELECT CASE num%
  862.             CASE 1
  863.                 Arg$ = Arg1$
  864.             CASE 2
  865.                 Arg$ = Arg2$
  866.             CASE 3
  867.                 Arg$ = Arg3$
  868.             CASE 4
  869.                 Arg$ = Arg4$
  870.             CASE ELSE
  871.                 Arg$ = ""
  872.             END SELECT
  873.             rtn$ = MID$(rtn$, 1, i% - 1) + Arg$ + MID$(rtn$, j%)
  874.             i% = i% + LEN(Arg$)        'next search pos in string
  875.         END IF
  876.     WEND
  877.  
  878.     ArgStr$ = rtn$
  879.  
  880. END FUNCTION
  881.